home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1995-12-31 | 43.9 KB | 1,199 lines | [ TEXT/R*ch]
C.S.M.P. Digest Wed, 05 Jul 95 Volume 3 : Issue 103 Today's Topics: Explanation of color palettes MoveControl for Modeless Dialogs Opening Control Panels from within an Application QT2.0 & NewMovieFromUserProc help... Selecting a DA Sound Manager - handling underrun in double-buffered playback ? [ANNOUNCE] MacTCP programmer's web page MOVED The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier (pottier@clipper.ens.fr). The digest is a collection of article threads from the internet newsgroups comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for people who read news semi-regularly and want an archive of the discussions. If you don't know what a newsgroup is, you probably don't have access to it. Ask your systems administrator(s) for details. If you don't have access to news, you may still be able to post messages to the group by using a mail server like anon.penet.fi (mail help@anon.penet.fi for more information). Each issue of the digest contains one or more sets of articles (called threads), with each set corresponding to a 'discussion' of a particular subject. The articles are not edited; all articles included in this digest are in their original posted form (as received by our news server at nef.ens.fr). Article threads are not added to the digest until the last article added to the thread is at least two weeks old (this is to ensure that the thread is dead before adding it to the digest). Article threads that consist of only one message are generally not included in the digest. The digest is officially distributed by two means, by email and ftp. If you want to receive the digest by mail, send email to listserv@ens.fr with no subject and one of the following commands as body: help Sends you a summary of commands subscribe csmp-digest Your Name Adds you to the mailing list signoff csmp-digest Removes you from the list Once you have subscribed, you will automatically receive each new issue as it is created. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest. Questions related to the ftp site should be directed to scott.silver@dartmouth.edu. ------------------------------------------------------- >From arnold@lumina.com (Brian Arnold) Subject: Explanation of color palettes Date: Thu, 15 Jun 1995 14:52:14 -0700 Organization: Lumina Decision Systems, Inc. I read, re-read, and re-re-read the Color QuickDraw chapters, hoping to find a magic bullet for "simple" use of color. Specifically, I want to be sure that about 7 colors are used correctly when at least 256 colors are shown, but I don't want to write a lot of code. If I use my colors without regard to the color manager or palette manager, and another application has taken up and modified available colors, my colors come out horrible. But every time I pick up my Inside Mac to read about the Color Manager or Palette Manager, my eyes go cross-eyed. Surely they meant for people to do simple things? So what's the easiest way to assure that the 7 colors I want to use are going to be correct. I know it can be done, but I want to do it in 10 lines of code or less, and I don't want to have to explain the Color Manager or Palette Manager in great detail to another engineer, should they have to modify those 10 lines in the future. Oh, and while we're at it, is there a way to re-sort the built-in 256 color palette so that colors are organized logically? It looks like 256 semi-randomly ordered colors. (See the ResEdit 256 color palette for an example of what I'm talking about, I display it the same way and don't want to). Tips, advice are greatly appreciated. - Brian -- Brian Arnold Director of Software Development Lumina Decision Systems, Inc. http://www.lumina.com/lumina/ +++++++++++++++++++++++++++ >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU> Date: Fri, 16 Jun 1995 11:37:59 -0400 Organization: Carnegie Mellon, Pittsburgh, PA arnold@lumina.com (Brian Arnold) writes: > I read, re-read, and re-re-read the Color QuickDraw chapters, hoping to > find a magic bullet for "simple" use of color. Specifically, I want to be > sure that about 7 colors are used correctly when at least 256 colors are > shown, but I don't want to write a lot of code. If I use my colors without > regard to the color manager or palette manager, and another application > has taken up and modified available colors, my colors come out horrible. Ok, what you want to do is this: Create a palette resource ('pltt', not 'clut') in ResEdit. Have it contain the colors you want, including black and white. Select all the colors (except black and white), hit the "Usage..." menu option, and set them to "Tolerant" with tolerance 0. In your program, when you create any window, use SetPalette to set that palette. Use TRUE as the second argument so that you get update events when the device's color table changes. Then use PmForeColor to set colors, using the index of the color in the palette. (Or RGBForeColor with the correct RGB values.) That should work in the simplest case: your app in the foreground and no other apps running. When other apps are in the foreground, of course, they can hog the color table for themselves. I *think* this will work when you are in the foreground and other apps are in the background, but it's probably possible for a badly-written app to hog the palette even when it's hidden. If so, there's nothing you can do about it (without being even ruder than it is.) This is from memory, so if it doesn't work, post again. --Z "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..." +++++++++++++++++++++++++++ >From h+@metrowerks.com (Jon Watte) Date: Sun, 18 Jun 1995 15:22:28 -0500 Organization: <CLASSIFIED> In article <arnold-1506951452140001@227.rahul.net>, arnold@lumina.com (Brian Arnold) wrote: > So what's the easiest way to assure that the 7 colors I want to use are > going to be correct. I know it can be done, but I want to do it in 10 Create and attach a palette to your window. This is simplest done by making a 'pltt' resource with the same ID as your 'WIND' ID, adn read in your window using GetNewCWindow(). Make sure color 0 is white and 1 is black, though, else strange things happen. Now, when you draw, call PMForeColor(x) where x is your color number (0=white, 1=black, 2=next color in palette...) to set the color you want to use. The Palette Manager will try and make every reasonable effort to keep your colors true on screen. You should set your colors to be pmTolerant, with a tolerance of 0. pmCorteous colors will NOT be as kindly treated. pmExplicit and/or pmAnimated colors are only for special tricks, like lava lamps and fades. > Oh, and while we're at it, is there a way to re-sort the built-in 256 > color palette so that colors are organized logically? It looks like 256 Not really. If every program wanted to set the actual index used in video memory, you'd get contention for the indexes. The palette manager defines logical numbers you can use, which it maps to a physical index that noone else uses. Cheers, / h+ --------------------------- >From carytork@aol.com (CaryTork) Subject: MoveControl for Modeless Dialogs Date: 19 Jun 1995 21:30:00 -0400 Organization: America Online, Inc. (1-800-827-6364) I am using MoveControl in a modeless dialog. However, if I move the control, I no longer get mouse click events on that control in my DialogSelect call. In other words, if I do _not_ move the control (just let it stay where it is when I created it with ResEdit), DialogSelect properly returns true (with the control ID) when the user clicks on the push button. However, if I move the control with MoveControl first, when I click on the button, nothing happens and DialogSelect returns false. In the moved control case, the button isn't even highlighted when I click on it. Am I missing something fundamental here? Here's a sample of the code I'm using: MoveControl( GetItemHandle( pDialogScores, PB_CLEAR ), rectScores.right - 180, rectScores.bottom - 20 ); if ( DialogSelect( pEvent, &pDialog, &sItem ) ) ProcessScoresButtonClick( sItem ); One last note of interest. I have another routine handle keyboard events for this modeless dialog, which highlights the control if enter/return is pressed. That highlighting works just fine whether the control is moved or not. Any help in this matter would be greatly appreciated. Cary +++++++++++++++++++++++++++ >From bb@lightside.com (Bob Bradley) Date: Tue, 20 Jun 1995 02:23:35 -0700 Organization: SPC In article <3s58ao$jo5@newsbf02.news.aol.com>, carytork@aol.com (CaryTork) wrote: >I am using MoveControl in a modeless dialog. However, if I move the >control, I no longer get mouse click events on that control in my >DialogSelect call. In other words, if I do _not_ move the control (just >let it stay where it is when I created it with ResEdit), DialogSelect >properly returns true (with the control ID) when the user clicks on the >push button. However, if I move the control with MoveControl first, when >I click on the button, nothing happens and DialogSelect returns false. In >the moved control case, the button isn't even highlighted when I click on >it. Am I missing something fundamental here? Here's a sample of the code >I'm using: I think the problem is that you are moving the control without telling the Dialog Manager. After moving the control, use SetDialogItem to set the controls' new location (with the iRect parameter). +++++++++++++++++++++++++++ >From dstone@chem.utoronto.ca (David Stone) Date: Tue, 20 Jun 1995 13:02:56 GMT Organization: University of Toronto Chemistry In article <bb-2006950223350001@user43.lightside.com>, bb@lightside.com (Bob Bradley) wrote: > > In article <3s58ao$jo5@newsbf02.news.aol.com>, carytork@aol.com (CaryTork) > wrote: > > >I am using MoveControl in a modeless dialog. However, if I move the > >control, I no longer get mouse click events on that control in my > >DialogSelect call. =====snip========= > > I think the problem is that you are moving the control without telling the > Dialog Manager. After moving the control, use SetDialogItem to set the > controls' new location (with the iRect parameter). I think this is right - the dialog manager keeps it's own list of item rectangles separate from the control's contrlRect. In the original case HiliteControl works because it uses the rect in the ControlRecord, not the dialog item list. The same thing happens in modal dialogs... Dave Stone +++++++++++++++++++++++++++ >From Dave Overton <doverton@iglou.com> Date: Tue, 20 Jun 1995 21:20:07 GMT Organization: DataStream Imaging Systems, Inc. You also have to call GetDItem() and SetDItem() with the changed rectangle to let the dialog manager know you have moved the item. ie GetDItem ( dialog, itemNo, &kind, &handle, &rect ); rect.left = newleft; rect.right = newright; rect.top = newtop; rect.bottom = newbottom; SetDItem ( dialog, itemNo, kind, handle, &rect ); Dave Overton +++++++++++++++++++++++++++ >From carytork@aol.com (CaryTork) Date: 20 Jun 1995 22:50:51 -0400 Organization: America Online, Inc. (1-800-827-6364) >>I think the problem is that you are moving the control without telling the >>Dialog Manager. After moving the control, use SetDialogItem to set the >>controls' new location (with the iRect parameter). Thanks! SetDItem() is exactly what I needed to do to get things to work correctly. I appreaciate the help. Cary --------------------------- >From rsandhu@cs.ucl.ac.uk (Raghbir Sandhu) Subject: Opening Control Panels from within an Application Date: Wed, 14 Jun 1995 12:49:53 GMT Organization: University College London Hi, I am working on small project where I need to open the ConfigPPP control panel, set a few parameters and then perform the dial-up. What I want to know is there a way of doing this from WITHIN the application itself? I don't want to rely on AppleScript code to do this. Any help is much appreciated. Response by email please. Thanks, Raghbir rsandhu@cs.ucl.ac.uk +++++++++++++++++++++++++++ >From andrew@adcode.demon.co.uk (Andrew Crane) Date: 18 Jun 1995 21:09:39 +0100 Organization: Adcode In article <rsandhu.803134193@cs.ucl.ac.uk>, rsandhu@cs.ucl.ac.uk (Raghbir Sandhu) wrote: : I am working on small project where I need to open the ConfigPPP control panel, : set a few parameters and then perform the dial-up. What I want to know is there : a way of doing this from WITHIN the application itself? I don't want to rely on : AppleScript code to do this. : : Any help is much appreciated. You may be better off doing it in a script anyway - at some stage you will have to poke an event into the queue to simulate the mouse-down on the Open button and then the go-away box. You can invoke it quite easily with OpenDeskAcc, as any interactive application can be opened in this way (that's how you implement the apple menu). The opened application then takes over as the foreground task and you're behind it. If you have elected to receive background time, you can check that it has opened, poke your events at it, tell it to go away and regain control as the foreground Appl. Andrew -- Andrew Crane, Egham, Surrey, England +++++++++++++++++++++++++++ >From peter@mail.peter.com.au (Peter Lewis) Date: Tue, 20 Jun 1995 17:03:22 +0800 Organization: iiNET Technologies [Sorry, I appear to be posting source code to alt.sources.mac. I know this is breaking a long standtion of posting only discussion, but I couldn't help myself] In article <rsandhu.803134193@cs.ucl.ac.uk>, rsandhu@cs.ucl.ac.uk (Raghbir Sandhu) wrote: >I am working on small project where I need to open the ConfigPPP control panel, >set a few parameters and then perform the dial-up. What I want to know is there >a way of doing this from WITHIN the application itself? I don't want to rely on >AppleScript code to do this. I'm not sure if this will solve your problem, but it gives me a chance to post my process handling code. The following uses AppleEvents (not AppleScript) to control the scriptable finder to open a control panel. It also has lots of other neat process handling code. Enjoy, Peter. unit MyProcesses; interface uses Types, Files, Memory, Processes; const application = 'APPL'; function FindApplication (creator: OSType; var fs: FSSpec): OSErr; function FindProcess (creator, typ: OSType; var process: ProcessSerialNumber; var fs: FSSpec): boolean; function LaunchWithDocument (creator, typ: OSType; fs: FSSpec; tofront: boolean):OSErr; function LaunchApp (creator, typ: OSType; tofront: boolean):OSErr; procedure QuitApplication (creator, typ: OSType); function LaunchFSSpec (var fs: FSSpec; tofront: boolean):OSErr; function FindControlPanel (fcreator: OSType; var fs: FSSpec): OSErr; function TellFinderToLaunch (fs: FSSpec; tofront: boolean): boolean; function OpenControlPanel (fcreator: OSType): boolean; implementation uses AppleEvents, Aliases, MySystemGlobals, MyUtils, MyAEUtils, Folders, GestaltEqu; procedure AddFSSToAEList (var list: AEDescList; row: integer; var fs: FSSpec); var fileAlias: AliasHandle; err: OSErr; begin err := NewAlias(nil, fs, fileAlias); if err = noErr then begin HLock(handle(fileAlias)); err := AEPutPtr(list, row, typeAlias, ptr(fileAlias^), fileAlias^^.aliasSize); DisposeHandle(handle(fileAlias)); end; end; function FindControlPanel (fcreator: OSType; var fs: FSSpec): OSErr; var pb: HParamBlockRec; i: integer; err: OSErr; begin err := FindFolder(kOnSystemDisk, kControlPanelFolderType, false, fs.vRefNum, fs.parID); if err = noErr then begin i := 1; repeat pb.ioNamePtr := @fs.name; pb.ioVRefNum := fs.vRefNum; pb.ioDirID := fs.parID; pb.ioFDirIndex := i; i := i + 1; err := PBHGetFInfoSync(@pb); if err = noErr then begin if (pb.ioFlFndrInfo.fdType = 'cdev') & (pb.ioFlFndrInfo.fdCreator = fcreator) then begin leave; end; end; until (err <> noErr); end; FindControlPanel := err; end; function TellFinderToLaunch (fs: FSSpec; tofront: boolean): boolean; var process: ProcessSerialNumber; err, junk: OSErr; targetAddress: AEDesc; fileList: AEDescList; theEvent, theReply: AppleEvent; sendmode: AESendMode; gv: longInt; finder_fs: FSSpec; begin err := -1; if (Gestalt(gestaltFinderAttr, gv) = noErr) & BTST(gv, gestaltOSLCompliantFinder) then begin if FindProcess('MACS', 'FNDR', process, finder_fs) then begin AECreate(theEvent); AECreate(theReply); AECreate(fileList); AECreate(targetAddress); err := AECreateDesc(typeProcessSerialNumber, @process, sizeof(process), targetAddress); if err = noErr then begin err := AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, targetAddress, kAutoGenerateReturnID, kAnyTransactionID, theEvent); end; AEDestroy(targetAddress); if err = noErr then begin err := AECreateList(nil, 0, false, fileList); end; if err = noErr then begin AddFSSToAEList(fileList, 1, fs); end; if err = noErr then begin err := AEPutParamDesc(theEvent, keyDirectObject, fileList); end; if err = noErr then begin sendmode := kAENoReply; if not tofront then begin sendmode := sendmode + kAENeverInteract; end; err := AESend(theEvent, theReply, sendmode, kAEHighPriority, kNoTimeOut, nil, nil); end; AEDestroy(theEvent); AEDestroy(theReply); AEDestroy(fileList); if (err = noErr) & tofront then begin junk := SetFrontProcess(process); end; end; end; TellFinderToLaunch := err = noErr; end; function OpenControlPanel (fcreator: OSType): boolean; var fs: FSSpec; begin OpenControlPanel := false; if FindControlPanel(fcreator, fs) = noErr then begin OpenControlPanel := TellFinderToLaunch(fs, true); end; end; function ConfirmApplicationExists (creator: OSType; var fs: FSSpec): OSErr; var err: OSErr; info: FInfo; begin err := HGetFInfo(fs.vRefNum, fs.parID, fs.name, info); if err = noErr then begin if (info.fdType <> 'APPL') or (info.fdCreator <> creator) then begin err := afpItemNotFound; end; (* if *) end; (* if *) ConfirmApplicationExists := err; end; function FindApplication (creator: OSType; var fs: FSSpec): OSErr; var i: integer; pbdt: DTPBRec; crdate: longInt; oe: OSErr; found: boolean; begin found := false; if system7 then begin i := 1; repeat fs.vRefNum := 0; oe := GetVolInfo(fs.name, fs.vRefNum, i, crdate); i := i + 1; if oe = noErr then begin with pbdt do begin fs.name := ''; ioNamePtr := @fs.name; ioVRefNum := fs.vRefNum; oe := PBDTGetPath(@pbdt); if oe = noErr then begin ioIndex := 0; ioFileCreator := creator; oe := PBDTGetAPPLSync(@pbdt); if oe = noErr then begin fs.parID := pbdt.ioAPPLParID; found := ConfirmApplicationExists(creator,fs)=noErr; end; end; end; oe := noErr; end; until found or (oe <> noErr); end; if found then begin oe := noErr; end else begin oe := afpItemNotFound; fs.vRefNum := 0; fs.parID := 2; fs.name := ''; end; FindApplication := oe; end; function FindProcess (creator, typ: OSType; var process: ProcessSerialNumber; var fs: FSSpec): boolean; var info: ProcessInfoRec; gv: longInt; begin FindProcess := false; if (Gestalt(gestaltOSAttr, gv) = noErr) & (BTST(gv, gestaltLaunchControl)) then begin process.highLongOfPSN := 0; process.lowLongOfPSN := kNoProcess; info.processInfoLength := sizeof(ProcessInfoRec); info.processName := nil; info.processAppSpec := @fs; while GetNextProcess(process) = noErr do begin if GetProcessInformation(process, info) = noErr then begin if (info.processType = longInt(typ)) and (info.processSignature = creator) then begin FindProcess := true; leave; end; end; end; end; end; procedure PrepareToLaunch (var theEvent: AppleEvent; tofront: boolean; var launchDesc: AEDesc; var launchThis: LaunchParamBlockRec); var oe: OSErr; begin oe := AECoerceDesc(theEvent, typeAppParameters, launchDesc); HLock(handle(theEvent.dataHandle)); launchThis.launchAppParameters := AppParametersPtr(launchDesc.dataHandle^); launchThis.launchBlockID := extendedBlock; launchThis.launchEPBLength := extendedBlockLen; launchThis.launchFileFlags := 0; launchThis.launchControlFlags := launchContinue + launchNoFileFlags; if not tofront then begin launchThis.launchControlFlags := launchThis.launchControlFlags + launchDontSwitch; end; end; function LaunchApplicationOptionallyMinimum(var launchThis: LaunchParamBlockRec):OSErr; var err:OSErr; begin err := LaunchApplication(@launchThis); if err = memFullErr then begin launchThis.launchControlFlags := BOR(launchThis.launchControlFlags, launchUseMinimum); err := LaunchApplication(@launchThis); end; LaunchApplicationOptionallyMinimum:=err; end; function LaunchWithDocument (creator, typ: OSType; fs: FSSpec; tofront: boolean):OSErr; var psn: ProcessSerialNumber; targetAddress: AEDesc; theEvent, theReply: AppleEvent; fileList: AEDescList; launchDesc: AEDesc; app_fs: FSSpec; launchThis: LaunchParamBlockRec; oe: OSErr; gv: longInt; sendmode: AESendMode; t, c: longInt; begin LaunchWithDocument := -1; PurgeSpace(t, c); if (Gestalt(gestaltOSAttr, gv) = noErr) & (BTST(gv, gestaltLaunchControl)) & (c > 4096) then begin if FindProcess(creator, typ, psn, app_fs) then begin oe := AECreateDesc(typeProcessSerialNumber, @psn, sizeof(psn), targetAddress); oe := AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, targetAddress, kAutoGenerateReturnID, kAnyTransactionID, theEvent); oe := AEDisposeDesc(targetAddress); oe := AECreateList(nil, 0, false, fileList); AddFSSToAEList(fileList, 1, fs); oe := AEPutParamDesc(theEvent, keyDirectObject, fileList); sendmode := kAENoReply; if not tofront then begin sendmode := sendmode + kAENeverInteract; end; oe := AESend(theEvent, theReply, sendmode, kAEHighPriority, kNoTimeOut, nil, nil); oe := AEDisposeDesc(theEvent); oe := AEDisposeDesc(theReply); oe := AEDisposeDesc(fileList); if tofront then begin LaunchWithDocument := SetFrontProcess(psn); end; end else begin if FindApplication(creator, app_fs) = noErr then begin oe := AECreateDesc(typeApplSignature, @creator, sizeof(creator), targetAddress); oe := AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, targetAddress, kAutoGenerateReturnID, kAnyTransactionID, theEvent); oe := AEDisposeDesc(targetAddress); oe := AECreateList(nil, 0, false, fileList); AddFSSToAEList(fileList, 1, fs); oe := AEPutParamDesc(theEvent, keyDirectObject, fileList); launchThis.launchAppSpec := @app_fs; PrepareToLaunch(theEvent, tofront, launchDesc, launchThis); LaunchWithDocument := LaunchApplicationOptionallyMinimum(launchThis); oe := AEDisposeDesc(theEvent); oe := AEDisposeDesc(fileList); end; end; end; end; function LaunchFSSpec (var fs: FSSpec; tofront: boolean):OSErr; var gv: longInt; launchThis: LaunchParamBlockRec; begin LaunchFSSpec := -1; if (Gestalt(gestaltOSAttr, gv) = noErr) & (BTST(gv, gestaltLaunchControl)) then begin launchThis.launchBlockID := extendedBlock; launchThis.launchEPBLength := extendedBlockLen; launchThis.launchFileFlags := 0; launchThis.launchControlFlags := launchContinue + launchNoFileFlags + launchUseMinimum; if not tofront then begin launchThis.launchControlFlags := launchThis.launchControlFlags + launchDontSwitch; end; launchThis.launchAppSpec := @fs; launchThis.launchAppParameters := nil; LaunchFSSpec := LaunchApplicationOptionallyMinimum(launchThis); end; end; function LaunchApp (creator, typ: OSType; tofront: boolean):OSErr; var psn: ProcessSerialNumber; app_fs: FSSpec; gv: longInt; begin LaunchApp := -1; if (Gestalt(gestaltOSAttr, gv) = noErr) & (BTST(gv, gestaltLaunchControl)) then begin if FindProcess(creator, typ, psn, app_fs) then begin if tofront then begin LaunchApp := SetFrontProcess(psn); end; end else begin if FindApplication(creator, app_fs) = noErr then begin LaunchApp := LaunchFSSpec(app_fs, tofront); end; end; end; end; procedure QuitApplication (creator, typ: OSType); var process: processSerialNumber; targetAddress: AEAddressDesc; AEvent, AReply: AppleEvent; fs: FSSpec; oe: OSErr; begin if FindProcess(creator, typ, process, fs) then begin oe := AECreateDesc(typeProcessSerialNumber, @process, SizeOf(process), targetAddress); oe := AECreateAppleEvent(kCoreEventClass, kAEQuitApplication, targetAddress, kAutoGenerateReturnID, kAnyTransactionID, AEvent); oe := AEDisposeDesc(targetAddress); oe := AESend(AEvent, AReply, kAENoReply, kAEHighPriority, 5 * 60, nil, nil); oe := AEDisposeDesc(AEvent); oe := AEDisposeDesc(AReply); end; end; end. -- And lo, NewsWatcher did say "comp.sys.mac.programmer: Group deleted on news server." Let February 7 hence forth be know as a day of mourning. --------------------------- >From rpa@netcom.com (Ramin Firoozye) Subject: QT2.0 & NewMovieFromUserProc help... Date: Wed, 21 Jun 1995 17:56:16 GMT Organization: NETCOM On-line Communication Services (408 261-4700 guest) [ I posted this on c.s.m.p but found it had been rendered defunct... Here it is again. Sorry for the duplication. R] - - [ This is a question for those who have dabbled in the bowels of the QuickTime 2.0 SDK... I'm also hoping someone from Apple may get this and get it to the right person. - R.] I was playing around with the new call "NewMovieFromUserProc". I'm wondering if maybe I'm missing something. The description in the manual (pp 3-6) is somewhat confusing. I have a simple movie which has been converted for non-mac use. I open the file using stdio calls. Then I use NewMovieFromUserProc and give it my own GetMovie procptr. As the refCon, I pass down the file descriptor for the opened movie file. It calls my procptr and asks for 8-bytes from offset 0. This all works great, no problems until NewMovieFromUserProc returns with a noMovieFound error. The description of the user-specified routine MyGetMovieProc says that it is passed an offset value that "specifies the offset into the movie resource (not the movie file). This is the location from which your function retrieves the movie data." I thought NewMovieFromUserProc was there so you could use it to get movie data. But the description all of a sudden says the offset is into the movie resource "NOT THE MOVIE FILE". Huh? Anyway, I had already converted the movie for non-mac use so all stuff was to come out of the data fork anyway. Right? For defaultDataRef I pass it a nil, since I've already opened the file myself. For dataRefType, I pass it 'alis' (the other choice being 'hndl'). I was under the impression that specifying a nil defaultDataRef meant the movie toolbox wouldn't try to do anything and would just let me take care of all I/O. I think I'm missing a crucial bit here. And the docs don't help clarify things... If I am to write my own data handler, then I thought the movie toolbox would invoke my read routines via DHScheduleData, so what do I need this getProcptr business for? On the other hand, if I can just use this function to get the data myself, why would I need a data handler? And why do I need to screw around with the resource fork? It seems the notion of the the getProcptr duplicates the data handler's DHScheduleData stuff. Or is it the case that *I'M* supposed to initiate DHScheduleData from inside the getProcptr. Holy bat-wings. It keeps getting curioser and curioser. Any help, pointers, tips would be greatly appreciated. Please, please, please, reply by mail and I'll summarize. I can never get through the whole csmp backlog. Thanks, Ramin. - rpa@netcom.com - Phone: (415) 826-3113. -- Ramin Firoozye' -- rp&A Inc. San Francisco, California. Internet: rpa@netcom.com --- CompuServe: 70751, 252 +++++++++++++++++++++++++++ >From ivanski@world.std.com (Ivan M CaveroBelaunde) Date: Wed, 21 Jun 1995 22:06:17 GMT Organization: The World Public Access UNIX, Brookline, MA rpa@netcom.com (Ramin Firoozye) writes: >[ I posted this on c.s.m.p but found it had been rendered defunct... > Here it is again. Sorry for the duplication. R] >--- >[ This is a question for those who have dabbled in the bowels of the >QuickTime 2.0 SDK... I'm also hoping someone from Apple may get this >and get it to the right person. - R.] >I was playing around with the new call "NewMovieFromUserProc". >I'm wondering if maybe I'm missing something. The description in the >manual (pp 3-6) is somewhat confusing. You're misunderstanding the purpose of NewMovieFromUserProc. The NewMovieWhatever calls basically read in a "public movie", a chunk of data in the format defined by MoviesFormat.h and the QT docs. The "public movie" is basically a *descriptor* for the actual media data and how it plays (tracks, media, timescales, spatial size, duration, etc.) but does not contain any of the actual *sample* data. Mac-centric QT movies stored the public movie in the 'moov' resource in the resource fork. Cross-platform QT movies store the public movie at the end of the data fork (with some twists; xplatform movies are actually composed of "atoms" [chunks of the file with an 8-byte header identifying the chunk and its length], of which the public movie is one). NewMovieFromUserProc allows you to feed in the data normally stored in the public movie (either the resource or the "public movie atom" at the end of a xplatform movie) from any source; it could be, for example, algorithmically generated (make for some funny movies). >I have a simple movie which has been converted for non-mac use. >I open the file using stdio calls. Then I use NewMovieFromUserProc >and give it my own GetMovie procptr. As the refCon, I pass down >the file descriptor for the opened movie file. It calls my procptr and >asks for 8-bytes from offset 0. This all works great, no problems until >NewMovieFromUserProc returns with a noMovieFound error. If you have a standard xplatform QT movie you should just use the standard NewMovieFromFile and OpenMovieFile calls with the magical movieInDataForkResID for the res ID in the call. <SNIKT> >I thought NewMovieFromUserProc was there so you could use it to get movie >data. But the description all of a sudden says the offset is into the >movie resource "NOT THE MOVIE FILE". Huh? Anyway, I had already converted >the movie for non-mac use so all stuff was to come out of the data fork >anyway. Right? Nope; NewMovieFromUserProc is not for getting the data as explained above. If you want to get at the movie data you need to use the GetMediaSample/GetMediaSampleReference calls. Navigation can be quite tricky as the QT hierarchy (Movie contains any number of tracks, potentially layered together; each track is an edit list of the media; media is a time-ordered sequence of samples; samples are chunk of raw data which sit in a file and are interpreted by the appropriate media handler) can allow for extremely complex combinations that can be really hard to walk. Oh, and the data handlers have nothing to do with this. Data handlers sit below the media handlers and fetch the data for it. -Ivan - - Ivan Cavero Belaunde (ivanski@world.std.com) --------------------------- >From davewise@aol.com (DaveWise) Subject: Selecting a DA Date: 20 Jun 1995 12:53:34 -0400 Organization: America Online, Inc. (1-800-827-6364) Ok. I am new to programming so go slow. I made an app that has a window this is very exciting for me. Now I want to add apple menu options as well. I have an about window which is cool but I can't get items in the apple menu other that my about to launch while my window is open. I am using openDeskAcc or whatever that toolbox call is. And as soon as I close my window the item that I chose (usually the calculator) is launched. +++++++++++++++++++++++++++ >From andrew@adcode.demon.co.uk (Andrew Crane) Date: 20 Jun 1995 23:10:12 +0100 Organization: Adcode In article <3s6uee$1dg@newsbf02.news.aol.com>, davewise@aol.com (DaveWise) wrote: : Ok. I am new to programming so go slow. I made an app that has a window : this is very exciting for me. Now I want to add apple menu options as : well. I have an about window which is cool but I can't get items in the : apple menu other that my about to launch while my window is open. I am : using openDeskAcc or whatever that toolbox call is. And as soon as I close : my window the item that I chose (usually the calculator) is launched. In article <3s6uee$1dg@newsbf02.news.aol.com>, davewise@aol.com (DaveWise) wrote: : Ok. I am new to programming so go slow. I made an app that has a window : this is very exciting for me. Now I want to add apple menu options as : well. I have an about window which is cool but I can't get items in the : apple menu other that my about to launch while my window is open. I am : using openDeskAcc or whatever that toolbox call is. And as soon as I close : my window the item that I chose (usually the calculator) is launched. 1. Need to add the desk accessories to the menu: AddResMenu(AppleMenu,'DRVR'); where AppleMenu is a handle to your apple menu's resource. 2. In your event loop, when a menu item is chosen in the mouseDown section, respond like this: (forget about the Boolean return - I've just pulled this from an unfinished application). The MenuItem variable is derived from the Boolean HandleAppleMenuChoice(short MenuItem) // ------------------------ { #define mAboutBox 16000 Str63 DeskAccName; short DeskAccNumber; if (MenuItem == 1) DisplayStandardAbout(); else { GetItem(AppleMenu, MenuItem, DeskAccName); DeskAccNumber = OpenDeskAcc(DeskAccName); } return false; } Other bits may help: to get the MenuChoice from the mouseDown event: MenuChoice = MenuSelect(TheEvent.where); To get the menu pad and menu item numbers from MenuChoice: TheMenu = HiWord(MenuChoice); MenuItem = LoWord(MenuChoice); (MenuItem was passed to the routine above). Regards Andrew, -- Andrew Crane, Egham, Surrey, England +++++++++++++++++++++++++++ >From larson@base.cs.ucla.edu (Christopher Larson) Date: 21 Jun 1995 19:12:38 GMT Organization: UCLA, Computer Science Department In article <3s6uee$1dg@newsbf02.news.aol.com> davewise@aol.com (DaveWise) writes: >Ok. I am new to programming so go slow. I made an app that has a window >this is very exciting for me. Now I want to add apple menu options as >well. I have an about window which is cool but I can't get items in the >apple menu other that my about to launch while my window is open. I am >using openDeskAcc or whatever that toolbox call is. And as soon as I close >my window the item that I chose (usually the calculator) is launched. Your event queue is getting clogged with update events. You need to respond to update events by calling BeginUpdate(), drawing the contents of your window, and then calling EndUpdate(). If you don't want to draw anything, fine, but yu still need to call BeginUpdate() and EndUpdate() or you will continuously receive update events and no background processes will recieve CPU time. --Chris _______________________________________________________________________________ Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious - -------------------------------------+--------------------------------------- (Insert Disclaimer Here) | Who's the man ridin' in the sun? UCLA Bruins--1995 NCAA Men's Basketball| Who's the man with the itchy gun? National Champions (yea!) | Who's the man who kills for fun? Internet: larson@kingston.cs.ucla.edu | Psycho Dad, Psycho Dad, PSYCHO DAD! --------------------------- >From P.T.Russell@sussex.ac.uk (Paul Russell) Subject: Sound Manager - handling underrun in double-buffered playback ? Date: Mon, 12 Jun 1995 16:53:40 +0100 Organization: Experimental Psychology, Sussex University If my doubleback procedure takes too long to execute, is there a possiblity that it will get called reentrantly to fill the next buffer, before it has finished filling the current one ? Or does the Sound Manager remember that the previous buffer has not yet been filled and generate an error ? I would guess that the former must be the case, since my application crashes if I try to do too much work in the doubleback procedure, but works fine otherwise. Does this mean that I need to keep track of whether I'm being called reentrantly and handle the underrun error condition accordingly ? //Paul -- | Paul Russell | Internet: P.T.Russell@sussex.ac.uk | | Experimental Psychology | AppleLink: EP.SUSSEX | | Sussex University, Falmer | Telephone: +44 1273 678639 | | Brighton BN1 9QG, England | Facsimile: +44 1273 678611 | +++++++++++++++++++++++++++ >From jons@ivi.com (Jon Steinmetz) Date: Tue, 13 Jun 1995 10:27:16 -0600 Organization: IVI Publishing, Inc. In article <P.T.Russell-1206951653400001@paul.biols.susx.ac.uk>, P.T.Russell@sussex.ac.uk (Paul Russell) wrote: > If my doubleback procedure takes too long to execute, is there a > possiblity that it will get called reentrantly to fill the next buffer, > before it has finished filling the current one ? Or does the Sound Manager > remember that the previous buffer has not yet been filled and generate an > error ? > Assuming that you have not marked the buffer as completed I do not think that your routine will be called again for that buffer. -- // Jon Steinmetz // IVI Publishing, Inc. // work: jons@ivi.com // personal: stein045@gold.tc.umn.edu // web page: http://www.umn.edu/nlhome/g262/stein045/ +++++++++++++++++++++++++++ >From P.T.Russell@sussex.ac.uk (Paul Russell) Date: Tue, 13 Jun 1995 18:12:48 +0100 Organization: Experimental Psychology, Sussex University In article <jons-1306951027160001@199.199.200.217>, jons@ivi.com (Jon Steinmetz) wrote: >In article <P.T.Russell-1206951653400001@paul.biols.susx.ac.uk>, >P.T.Russell@sussex.ac.uk (Paul Russell) wrote: > >> If my doubleback procedure takes too long to execute, is there a >> possiblity that it will get called reentrantly to fill the next buffer, >> before it has finished filling the current one ? Or does the Sound Manager >> remember that the previous buffer has not yet been filled and generate an >> error ? >> > > Assuming that you have not marked the buffer as completed I do not think >that your routine will be called again for that buffer. > Ah, yes, but I have one routine which handles both buffers. I would imagine that this is a fairly typical scenario (?). So, if my routine is still filling buffer[0] when it becomes time to fill up buffer[1], I'm wondering whether the Sound Manager is smart enough not to call my doubleback procedure reentrantly, or whether I have to handle this case myself ? I guess it might already have given up at this point if buffer[0] wasn't flagged as ready ? I have actually added some code to my doubleback routine now, so that it won't get confused if it's called reentrantly, but it's not an easy thing to test... //Paul -- | Paul Russell | Internet: P.T.Russell@sussex.ac.uk | | Experimental Psychology | AppleLink: EP.SUSSEX | | Sussex University, Falmer | Telephone: +44 1273 678639 | | Brighton BN1 9QG, England | Facsimile: +44 1273 678611 | +++++++++++++++++++++++++++ >From h+@metrowerks.com (Jon Watte) Date: Thu, 15 Jun 1995 10:38:50 -0500 Organization: <CLASSIFIED> In article <P.T.Russell-1306951812480001@paul.biols.susx.ac.uk>, P.T.Russell@sussex.ac.uk (Paul Russell) wrote: > I have actually added some code to my doubleback routine now, so that it > won't get confused if it's called reentrantly, but it's not an easy thing > to test... Create an OSQueue with only one item. Dequeue the item when entering, and enqueue when leaving. This is an atomic (semaphore) operation. If the queue's empty when entering, you're being re-entered. Cheers, / h+ +++++++++++++++++++++++++++ >From hawkfish@punchdeck.com (Richard Wesley) Date: 19 Jun 1995 21:15:06 GMT Organization: Punch Deck Consulting In article <AC05BE3A966816D3C@slip11.metrowerks.com> h+@metrowerks.com (Jon Watte) writes: > Create an OSQueue with only one item. Dequeue the item when entering, and > enqueue when leaving. This is an atomic (semaphore) operation. If the > queue's empty when entering, you're being re-entered. class Semaphore { protected: QElem mElem; QHdr mQueue; public: Semaphore (Boolean inState) {mQueue.qHead = mQueue.qTail = nil; if (!inState) Unlock ();}; OSErr Lock (void) {return ::Dequeue (&mElem, &mQueue);}; void Unlock (void) {if (!mQueue.qHead) ::Enqueue (&mElem, &mQueue);}; }; - rmgw http://www.halcyon.com/hawkfish/Resume.html - ---------------------------------------------------------------------------- Richard Wesley hawkfish@punchdeck.com | "Oh boy! Did you forget the plot Punch Deck Consulting pnchdeck@aol.com | _again_?" Macintosh Software Development | - Rocket J. Squirrel - ---------------------------------------------------------------------------- --------------------------- >From scouten@metrowerks.com (Eric Scouten) Subject: [ANNOUNCE] MacTCP programmer's web page MOVED Date: Mon, 19 Jun 1995 18:10:05 -0500 Organization: metrowerks, inc. The MacTCP Programmer's Web page that I've been maintaining for the last year or so has been moved and updated. It can now be found at: http://www.metrowerks.com/tcpip/index.html Forwarding links will be available at the old site for a short period of time. As a favor to the sys admin at that machine, I ask that you please update any printed or hypertext links to the old site as soon as possible. Thanks and enjoy the new site! -es __________________________________________________________________________ Eric Scouten Constructor Constructor scouten@metrowerks.com Metrowerks, Inc. --------------------------- End of C.S.M.P. Digest **********************